﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataBadCodeTemplate" @search="()=>{getTableDataBadCodeTemplate();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AddTime_FormItem" prop="AddTime" :label="$t('message.autotrans._Model_BadCodeTemplate_addTime')">
            <el-date-picker v-model="searchDataBadCodeTemplate.AddTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="BadCode_FormItem" prop="BadCode" :label="$t('message.autotrans._Model_BadCodeTemplate_badCode')">
            <el-input v-model="searchDataBadCodeTemplate.BadCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="BadName_FormItem" prop="BadName" :label="$t('message.autotrans._Model_BadCodeTemplate_badName')">
            <el-input v-model="searchDataBadCodeTemplate.BadName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="BadTypeCode_FormItem" prop="BadTypeCode" :label="$t('message.autotrans._Model_BadCodeTemplate_badTypeCode')">
            <el-input v-model="searchDataBadCodeTemplate.BadTypeCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="BadTypeName_FormItem" prop="BadTypeName" :label="$t('message.autotrans._Model_BadCodeTemplate_badTypeName')">
            <el-input v-model="searchDataBadCodeTemplate.BadTypeName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataStatus_FormItem" prop="DataStatus" :label="$t('message.autotrans._Model_BadCodeTemplate_dataStatus')">
            <el-input v-model="searchDataBadCodeTemplate.DataStatus" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EditTime_FormItem" prop="EditTime" :label="$t('message.autotrans._Model_BadCodeTemplate_editTime')">
            <el-date-picker v-model="searchDataBadCodeTemplate.EditTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EnableStatus_FormItem" prop="EnableStatus" :label="$t('message.autotrans._Model_BadCodeTemplate_enableStatus')">
            <el-input v-model="searchDataBadCodeTemplate.EnableStatus" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="FactoryCode_FormItem" prop="FactoryCode" :label="$t('message.autotrans._Model_BadCodeTemplate_factoryCode')">
            <el-input v-model="searchDataBadCodeTemplate.FactoryCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field1_FormItem" prop="Field1" :label="$t('message.autotrans._Model_BadCodeTemplate_field1')">
            <el-input v-model="searchDataBadCodeTemplate.Field1" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field2_FormItem" prop="Field2" :label="$t('message.autotrans._Model_BadCodeTemplate_field2')">
            <el-input v-model="searchDataBadCodeTemplate.Field2" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field3_FormItem" prop="Field3" :label="$t('message.autotrans._Model_BadCodeTemplate_field3')">
            <el-input v-model="searchDataBadCodeTemplate.Field3" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field4_FormItem" prop="Field4" :label="$t('message.autotrans._Model_BadCodeTemplate_field4')">
            <el-input v-model="searchDataBadCodeTemplate.Field4" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field5_FormItem" prop="Field5" :label="$t('message.autotrans._Model_BadCodeTemplate_field5')">
            <el-input v-model="searchDataBadCodeTemplate.Field5" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OperationCode_FormItem" prop="OperationCode" :label="$t('message.autotrans._Model_BadCodeTemplate_operationCode')">
            <el-input v-model="searchDataBadCodeTemplate.OperationCode" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
    <el-popconfirm title="确定同步吗？" @confirm="Synchronous">
            <template #reference>
                <el-button style="width: 120px; height: 32px;margin-right: 10px;" type="primary">不良模板数据同步</el-button>
            </template>
        </el-popconfirm>
      <WtmButton v-auth="'/api/GetData/BadCodeTemplate/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/GetData/BadCodeTemplate/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/GetData/BadCodeTemplate/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/GetData/BadCodeTemplate/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/GetData/BadCodeTemplate/BadCodeTemplateExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefBadCodeTemplate" v-bind="tableDataBadCodeTemplate">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/GetData/BadCodeTemplate/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/GetData/BadCodeTemplate/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/GetData/BadCodeTemplate/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageGetDataBadCodeTemplateIndex;true;TyMES.GetData.Controllers;BadCodeTemplate">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { badcodetemplateApi } from '/@/api/getdata/badcodetemplate';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;
import request from '/@/utils/request';

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateBadCodeTemplate = reactive({
    
});

const searchDataBadCodeTemplate = ref({
        AddTime: undefined,
        BadCode: '',
        BadName: '',
        BadTypeCode: '',
        BadTypeName: '',
        DataStatus: '',
        EditTime: undefined,
        EnableStatus: '',
        FactoryCode: '',
        Field1: '',
        Field2: '',
        Field3: '',
        Field4: '',
        Field5: '',
        OperationCode: '',
});

// 定义变量内容
const tableRefBadCodeTemplate = ref();
const tableDataBadCodeTemplate = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page添加时间'),key: 'BadCodeTemplate_addTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page不良编码'),key: 'BadCodeTemplate_badCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page不良名称'),key: 'BadCodeTemplate_badName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page不良类型编码'),key: 'BadCodeTemplate_badTypeCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page不良类型名称'),key: 'BadCodeTemplate_badTypeName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据状态'),key: 'BadCodeTemplate_dataStatus',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page编辑时间'),key: 'BadCodeTemplate_editTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page启用状态'),key: 'BadCodeTemplate_enableStatus',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工厂编码'),key: 'BadCodeTemplate_factoryCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域1'),key: 'BadCodeTemplate_field1',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域2'),key: 'BadCodeTemplate_field2',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域3'),key: 'BadCodeTemplate_field3',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域4'),key: 'BadCodeTemplate_field4',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域5'),key: 'BadCodeTemplate_field5',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工艺编码'),key: 'BadCodeTemplate_operationCode',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataBadCodeTemplate = () => {
    tableRefBadCodeTemplate.value.doSearch(badcodetemplateApi().search, searchDataBadCodeTemplate.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataBadCodeTemplate)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataBadCodeTemplate)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataBadCodeTemplate)
};

// 删除
const onDelete = (row: any) => {
    badcodetemplateApi().delete([row.ID]).then(() => { getTableDataBadCodeTemplate()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefBadCodeTemplate.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      badcodetemplateApi().delete(selectedids).then(() => { getTableDataBadCodeTemplate()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefBadCodeTemplate.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataBadCodeTemplate)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataBadCodeTemplate)
};

const onExport = () => {
	const selected = tableRefBadCodeTemplate.value.getSelectedRows();
	if (selected.length > 0) {
		badcodetemplateApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		badcodetemplateApi().export({});
	}
};

function Synchronous(){
  request({
        url: '/api/GetData/BadCodeTemplate/SysncBadTemplate',
        method: 'get',
        data: {
            'id':''
        }
    })
}

// 页面加载时
onMounted(() => {
    
        getTableDataBadCodeTemplate();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

